package com.zhixi.pattern.notimportant.flyweightpattern.operation;

import java.util.HashMap;
import java.util.Map;

/**
 * @作者 ShuHaoNan
 * @邮箱 shuhaonan1@gmail.com
 * @时间 2020/11/20 14:55
 */
public class SignInfoFactory {

    /* 容器池 */
    private static Map<String, SignInfo> pool = new HashMap<>();

    public static SignInfo getSignInfo(String key) {
        SignInfo result = null;
        /* 池中没有对象 */
        if (!pool.containsKey(key)) {
            System.out.println(key + "创建对象，并放入池中");
            result = new SignInfo4Pool(key);
            pool.put(key, result);
        } else {
            result = pool.get(key);
            System.out.println(key + "直接从池中取");
        }
        return result;
    }

}
